
public class ShowingList {
	private ShowingNode head; //link to head node
	private int numberOfItems; //number of items in LL
	
	//Constructor
	public ShowingList() {
		head = null; //set head to null
		numberOfItems = 0; //initiate numberOfItems to 0
	}
	
	//Method Header
	public int size() {
		return numberOfItems;
	}
		
	//Method Header
	public boolean isEmpty() {
		return (numberOfItems == 0);
	}
	
	//Method Header
	public void addShowing(Showing showing) {
		//Find location for showing
		ShowingNode newShowingNode = new ShowingNode(showing); //new show node
		ShowingNode currShowing = head; //track the list
		ShowingNode prevShowing = null;	//track last node
		
		if(currShowing == null) { //if empty list
			head = newShowingNode; //add at the head
			numberOfItems++;
			return;
		}
		else {
			final int COMES_BEFORE = 1;
			final int COMES_AFTER = 2;
			int compareResult = newShowingNode.checkOrder(currShowing);
			switch(compareResult) {
			case COMES_BEFORE:
				if(prevShowing == null) {
					head = newShowingNode;
					newShowingNode.setNext(currShowing);
				}
				else {
					prevShowing.setNext(newShowingNode);
					newShowingNode.setNext(currShowing);
				}
				break;
			case COMES_AFTER:
				prevShowing = currShowing;
				currShowing = currShowing.getNext();
				break;
			}
		}
	}
	
	public ShowingNode getHead() {
		return head;
	}
}
